<?php defined('InNcPHP') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3><?php echo $lang['ticket_cate_index_class'];?></h3>
      <?php echo $output['top_link'];?>
    </div>
  </div>
  <div class="fixed-empty"></div>
   <table class="table tb-type2" id="prompt">
    <tbody>
      <tr class="space odd">
        <th class="nobg" colspan="12"><div class="title"><h5><?php echo $lang['nc_prompts'];?></h5><span class="arrow"></span></div></th>
      </tr>
      <tr>
        <td>
        <ul>
            <li><?php echo $lang['ticket_cate_index_help'];?></li>
          </ul></td>
      </tr>
    </tbody>
  </table>
  <form method='post'>
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="submit_type" id="submit_type" value="" />
    <table class="table tb-type2">
      <thead>
        <tr class="thead">
          <th></th>
          <th><?php echo $lang['nc_sort'];?></th>
          <th><?php echo $lang['ticket_cate_index_name'];?></th>
          <th><?php echo $lang['ticket_cate_index_subname'];?></th>
          <th><?php echo $lang['ticket_cate_index_icon']; ?></th>
          <th><?php echo $lang['nc_handle'];?></th>
        </tr>
      </thead>
      <tbody>
      <?php if (!empty($output['class_list']) && is_array($output['class_list'])) { ?>
          <?php foreach ($output['class_list'] as $k => $v) { ?>
          <tr>
              <td><img sid="<?php echo $v['tc_id'];?>" status="open" src="<?php echo ADMIN_TEMPLATES_URL;?>/images/tv-expandable.gif"></td>
              <td><?php echo $v['tc_sort'];?></td>
              <td><?php echo $v['tc_name'];?></td>
              <td><?php echo $v['tc_subname'];?></td>
              <td><span class="tc_preview" style="cursor: pointer;">[预览]</span><img src="<?php echo $v['tc_icon'];?>" style="display: none;position: fixed;max-width: 100px;border: 1px  solid #000;"></td>
              <td>
                  <!-- <a href="index.php?act=ticket_category&op=add&pid=<?php echo $v['tc_id'];?>"><span><?php echo $lang['nc_add_sub_class'];?></span></a> | -->
                  <a href="index.php?act=ticket_category&op=edit&id=<?php echo $v['tc_id'];?>"><?php echo $lang['nc_edit'];?></a>
                  <!-- <a href="javascript:;" onclick="delCate(<?php echo $v['tc_id']; ?>)"><?php echo $lang['nc_del'];?></a> -->
              </td>
          </tr>
          <?php foreach ($v['child'] as $kk => $vv) { ?>
          <tr class="pid_<?php echo $v['tc_id'];?>" style="display: none;">
              <td></td>
              <td><?php echo $vv['tc_sort'];?></td>
              <td>
                  <img src="<?php echo ADMIN_TEMPLATES_URL;?>/images/tv-item1.gif">
                  <?php echo $vv['tc_name'];?>
              </td>
              <td><?php echo $vv['tc_subname'];?></td>
              <td><span class="tc_preview" style="cursor: pointer;">[预览]</span><img src="<?php echo $vv['tc_icon'];?>" style="display: none;position: fixed;max-width: 100px;border: 1px  solid #000;"></td>
              <td>
                  <a href="index.php?act=ticket_category&op=edit&id=<?php echo $vv['tc_id'];?>"><?php echo $lang['nc_edit'];?></a>
                 <a href="javascript:;" onclick="delCate(<?php echo $vv['tc_id']; ?>)"><?php echo $lang['nc_del'];?></a>
              </td>
          </tr>
          <?php } ?>
          <?php } ?>
      <?php } else { ?>
          <tr class="no_data">
              <td colspan="10"><?php echo $lang['nc_no_record'];?></td>
          </tr>
      <?php } ?>
      </tbody>
    </table>
  </form>
</div>
<script>

    //删除分类
    function delCate(id) {
        layer.confirm('<?php echo $lang['ticket_cate_index_del'];?>', {
            btn: ['<?php echo $lang['nc_yes']; ?>', '<?php echo $lang['nc_no']; ?>']
        }, function (index) {
            location.href='index.php?act=ticket_category&op=del&id=' + id;
        });
    }

    //显示子级
    $('img[sid]').click(function () {
        var that = $(this);
        var id = that.attr('sid'),
            status = that.attr('status');
        if (status == 'open') {
            that.attr('src', '<?php echo ADMIN_TEMPLATES_URL;?>/images/tv-collapsable.gif');
            that.attr('status', 'close');
            $('.pid_' + id).show(100);
        } else {
            that.attr('src', '<?php echo ADMIN_TEMPLATES_URL;?>/images/tv-expandable.gif');
            $('.pid_' + id).hide(100);
            that.attr('status', 'open');
        }
    });
    //预览
    $('.tc_preview').mouseover(function () {
        $(this).next().show();
    }).mouseleave(function () {
        $(this).next().hide();
    });
</script>
